package client;

public class GameMap {
	TerrainType[][] terrain;
	int xSize, ySize;
	public GameMap(int xGridSquares, int yGridSquares) {
		xSize = xGridSquares; 
		ySize = yGridSquares;
		terrain = new TerrainType[xSize][ySize];
		for(int x=0; x<xSize; x++) 
			for(int y=0; y<ySize; y++) {
				TerrainType t = TerrainType.LAND;
				if(x>40&&x<60&&y>40&&y<60)
					t = TerrainType.WATER;
				if(x>60&&x<80&&y>40&&y<60)
					t = TerrainType.WALL;
				if(x>15&&x<25&&y>20&&y<80)
					t = TerrainType.WALL;
				double dx,dy,dist;
				dx = x-150;
				dy = y-50;
				dist = Math.sqrt(dx*dx+dy*dy);
				if(dist>30&&dist<40)
					t = TerrainType.WATER;
				else if(dist<=30)
					t = TerrainType.WALL;
				dx = x-200;
				dy = y-100;
				dist = Math.sqrt(dx*dx+dy*dy);
				if(dist>15&&dist<17&&y<97)
					t = TerrainType.WALL;
				dx = x-200;
				dy = y;
				dist = Math.sqrt(dx*dx+dy*dy);
				if(dist>15&&dist<17&&y>3)
					t = TerrainType.WALL;
				
				terrain[x][y] = t;
			}
	}
	public TerrainType getTerrain(int x, int y) {
		if(x<0||x>=xSize||y<0||y>=ySize)
			return TerrainType.OUT_OF_BOUNDS;
		return terrain[x][y];
	}
	public int getXmax() {
		return xSize;
	}
	public int getYmax() {
		return ySize;
	}
}
